package com.example.administrator.basedemos.fragment;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.administrator.basedemos.R;
import com.example.administrator.basedemos.activity.AiVoiceRecorgnitionActivity;
import com.example.administrator.basedemos.activity.BlutoothActivity;
import com.example.administrator.basedemos.activity.Dagger2Activity;
import com.example.administrator.basedemos.activity.IconicsActivity;
import com.example.administrator.basedemos.activity.InterViewQuestionActivity;
import com.example.administrator.basedemos.activity.MakeViewActivity;
import com.example.administrator.basedemos.activity.MyPicBaseRxActivity;
import com.example.administrator.basedemos.activity.Okhttp3Activity;
import com.example.administrator.basedemos.activity.PhoneListenerActivity;
import com.example.administrator.basedemos.activity.Retrofit2Activity;
import com.example.administrator.basedemos.activity.RetrofitEduActivity;
import com.example.administrator.basedemos.activity.RetrofitEduRXActivity;
import com.example.administrator.basedemos.activity.Rxjava2Activity;
import com.example.administrator.basedemos.activity.Rxjava2_1Activity;
import com.example.administrator.basedemos.activity.SVGActivity;
import com.example.administrator.basedemos.activity.SubComponentActivity;
import com.example.administrator.basedemos.activity.SubjectOberserableActivity;
import com.example.administrator.basedemos.adapter.MainAdapter;
import com.example.administrator.basedemos.adapter.MarKetVPAdapter;
import com.example.administrator.basedemos.utils.LogUtil;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * 创建者     ZCL
 * 创建时间   2018/7/3 17:17
 * 描述	      ${TODO}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class HomeFragment extends BaseFragment {
    private static final String TAG = "HomeFragment";
    @BindView(R.id.recyclerview_weight)
    RecyclerView mRecyclerview;

    private Class<?>[] ACTIVITY = {Okhttp3Activity.class, Retrofit2Activity.class, RetrofitEduActivity.class
            , RetrofitEduRXActivity.class, Rxjava2Activity.class, Rxjava2_1Activity.class, Dagger2Activity.class,
            SubjectOberserableActivity.class, SubComponentActivity.class, MyPicBaseRxActivity.class, SVGActivity.class,
            IconicsActivity.class, BlutoothActivity.class, AiVoiceRecorgnitionActivity.class,PhoneListenerActivity.class
            ,InterViewQuestionActivity.class,MakeViewActivity.class};

    private String[]   TITLE    = {"Okhttp3", "Retrofit", "RetrofitEduActivity", "RetrofitEduRxActivity", "Rxjava2",
            "Rxjava2.1", "Dagger2", "SubjectOberserable", "SubcomponentActivity", "MyPicBaseRxActivity", "svg", "iconice", "蓝牙"
            , "语音识别","手机监听","面试点","自定义view"};


    @Override
    public int setLayoutId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initData() {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < TITLE.length; i++) {
            list.add( TITLE[i]);
        }

        mRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        MainAdapter mAdapter = new MainAdapter(R.layout.main_item, list);
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                LogUtil.util(TAG, "------:" + ACTIVITY[position]);
                Intent intent = new Intent(getActivity(), ACTIVITY[position]);
                startActivity(intent);
            }
        });
        mRecyclerview.setAdapter(mAdapter);
    }

}
